The present invention relates generally to a method, system, and apparatus for minimizing run-time exception handling overhead from invoked function calls.
Computer-based compiler technologies typically include operations that manage invocation of functions. The functions may be methods and the invoking method may be a caller and the invoked method may be a callee. Also, compiler technologies manage exception handling so that the occurrence of a hardware or software error condition during execution of code will change the normal flow of control in a program. An exception that occurs during the execution of a callee is typically handled by the caller upon return from the callee.
More particularly, when a caller receives a return transmission from a callee, a check for an exception is performed. Therefore, as shown in FIG. 1, even when both the caller and the callee are compiled methods 105 thereby making the callee capable of managing exception checking explicitly, the callee does not have sufficient information about the caller 101 to explicitly return to the caller exception handling code. Therefore, as shown in element 102, after the execution of a function call 330 (as shown in FIG. 3) from a compiled method 105 to another compiled method 105, the callee may encounter an exception as shown in element 104. Then the callee 103 determines if the method can handle the exception as shown in element 106. When the test of element 106 is true, the exception is handled and execution proceeds, as shown in 108, until the flow of execution returns to the caller as shown in element 110.
Alternatively, when the test of element 106 fails the callee 103 returns to the caller 101 as shown in element 110. Then the exception checking code of the caller 101 is executed as shown in element 112. More particularly, the test for the exception is performed by the caller as shown in element 114. If the test of element 114 is false then the exception handling label is executed as shown in element 116. Alternatively, if the test of element 114 is true normal execution continues as shown in element 118.
It would be useful if fewer checks for exceptions were required upon a return from a function call. More particularly, it would be useful if invoked compiled methods were able to avoid executing extra exception checking and handling code.
The present invention relates generally to a method, system, and apparatus for minimizing run-time exception handling overhead from invoked function calls.
The present embodiment novelly eliminates redundant exception checking code in a caller when the callee is a compiled method. More particularly, when the callee has encountered an exception during execution that it cannot handle, the callee explicitly returns to the exception handling label of the caller. Thereby the callee eliminates the execution of exception checking code in the caller method.
In the present embodiment the callee novelly treats the caller as a compiled method thereby enabling location of both the exception handling label and the point of normal execution that follows the exception handling code of the caller. Thereby the callee may return to the exception handling label of the caller if an exception needs to be handled and may return to the caller to continue normal code execution if an exception does not need to be handled. Therefore, the present embodiment novelly eliminates redundant execution of exception checking code and executes exception handling code only when it is necessary.
A compiled method is typically generated during the run-time portion of execution and a native method is typically generated during the compile-time portion of execution. Therefore, in the present embodiment the callee novelly takes advantage of the structure of a caller that is a compiled method to locate both the exception handling label and the point of normal execution that follows the exception handling code of the caller, and thereby eliminate execution of the exception checking code of the caller.
Further, the present embodiment novelly creates code with the layout of a compiled method when a caller is not a compiled method. Thereby the callee that is a compiled method eliminates redundant exception checking code in a caller regardless of whether the caller is a compiled method.